[Client encryption]: Adds new tests for EncryptionProcessor#5349
Merged
kirankumarkolli merged 26 commits intoAzure:masterfrom Oct 15, 2025
Merged
Conversation
- Change private methods to internal in EncryptionProcessor for better testability: - TypeMarker enum, Serialize, DeserializeAndAddProperty methods - EncryptJTokenAsync, DecryptJTokenAsync for JToken-level operations - ConvertToBase64UriSafeString/ConvertFromBase64UriSafeString utilities - Add test-only constructor to EncryptionSettingForProperty with injected algorithm - Improve EncryptionSettings constructor visibility and organization - Reorganize method placement for better code structure - Add proper validation and documentation to constructors These changes enable comprehensive unit testing while maintaining encapsulation of the core encryption functionality.
- Add coverlet.collector package for code coverage collection - Remove unused conditional package references for netstandard2.0 and net46 - Clean up project file by removing obsolete framework-specific dependencies - Ensure consistent test tooling across the project
- Add TestCryptoHelpers with DummyKeyEncryptionKey for test isolation - Create factory methods for encryption algorithms and settings - Enable end-to-end encryption testing without external key providers - Centralize test crypto setup to reduce code duplication across tests - Add empty UnsafeAccessors.Net8.cs placeholder for future .NET 8 support
- Add tests for patch operation validation on encrypted paths - Verify Increment operations are blocked on encrypted properties - Test that non-encrypted paths allow patch operations to pass through - Ensure proper error messaging when increment operations are attempted on encrypted fields - Cover both positive and negative test scenarios for patch operation encryption
- Test diagnostics data collection during encrypt/decrypt operations - Verify properties encrypted/decrypted counts are captured correctly - Ensure start time and duration are recorded in diagnostics context - Test diagnostics behavior with null properties and edge cases - Cover both encrypt and decrypt diagnostic data collection scenarios
- Add comprehensive round-trip encryption/decryption tests - Test primitive types (string, int, bool, double), arrays, and nested objects - Verify proper handling of large Unicode strings and special characters - Test ID field escaping for URL-safe Base64 encoding - Add tests for DateTime/DateTimeOffset rejection with proper error messages - Test feed response decryption and aggregation scenarios - Cover cancellation token handling (current pass-through behavior) - Test invalid Base64 handling and error propagation
- Test null argument validation for EncryptAsync and DecryptAsync - Verify proper error handling when encryption settings are missing - Test behavior when properties are configured but mappings are missing - Ensure proper ArgumentException messages for invalid configurations - Test stream disposal behavior on validation failures - Cover edge cases in settings validation and error propagation
- Add comprehensive TypeMarker serialization round-trip tests - Test boolean, long, double, and string serialization/deserialization - Verify proper handling of special double values (NaN, Infinity) - Test very large string serialization (1 MiB) for performance validation - Add tests for decimal to double coercion with precision loss - Test unsupported type rejection (Guid, byte[], TimeSpan, Uri) - Verify proper error messages for invalid type operations - Add overflow handling tests for numeric type edge cases
- Test Base64 URI-safe encoding for ID fields with problematic characters - Verify proper escaping of '/', '+', '?', '#', '\' characters in IDs - Test round-trip encoding/decoding without data loss - Add Unicode string testing with emojis and multi-byte characters - Test large mixed-Unicode ID strings for performance validation - Ensure no whitespace padding in encoded results - Verify proper handling of URL-unsafe characters in encrypted IDs
- Test encryption/decryption with deeply nested JSON structures - Verify handling of documents approaching MaxDepth limit (64 levels) - Test JSON traversal with complex nested objects and arrays - Add tests for null-only leaf traversal without crypto operations - Verify proper structural preservation during deep traversal - Test escaping behavior in nested document structures - Ensure performance with large nested documents
- Test proper stream disposal behavior in encrypt/decrypt operations - Verify new stream instances are returned from operations - Test seekable stream requirements for decrypt operations - Add tests for null input stream handling - Test no-op decryption scenarios with empty property configurations - Verify zero counts returned when no properties are configured for decryption - Test scenarios where properties are configured but not present in documents
- Test DeserializeAndDecryptResponseAsync with various feed shapes - Verify proper handling of empty Documents arrays - Test mixed document types in feed responses (objects, primitives) - Add validation for required 'Documents' property in feed responses - Test error handling for malformed feed response structures - Verify diagnostics aggregation across multiple documents in feeds - Test deeply nested documents within feed responses - Ensure proper feed contract validation and error messaging
- Add randomized encryption algorithm tests verifying different ciphertexts - Test that randomized encryption produces different ciphers for same input - Verify both ciphertexts decrypt back to original data correctly - Add diagnostics edge case tests for missing/null properties - Test diagnostic counting with various property configurations - Add placeholder tests for null crypto path validation (requires test seam) - Cover diagnostic behavior when properties are configured but missing from documents
- Update Visual Studio solution file to newer version (17.14.36301.6) - Add VS Code tasks.json with dotnet build tasks for development workflow - Configure build tasks with proper error formatting and console logging - Support multiple build task entries for different project contexts - Enable better development experience with IDE integration
- Add placeholder UnsafeAccessors.Net8.cs file for future .NET 8 features - Maintain directory structure for upcoming .NET 8 specific implementations - Prepare infrastructure for potential unsafe accessor patterns in .NET 8
…l classes - Consolidated 19+ fragmented test classes into 5 logical groupings - Replaced arbitrary test splitting with functionality-based organization - Created single EncryptionProcessorTests partial class structure: • CoreFunctionality.cs - End-to-end encryption/decryption, stream handling, JSON traversal • Validation.cs - Argument validation, settings validation, unsupported types • EdgeCases.cs - Depth handling, overflow scenarios, no-op operations, diagnostics • DataFormatEncoding.cs - ID escaping, Unicode handling, feed responses, value streams • Cryptography.cs - Randomized algorithms, encryption modes, key management Benefits: - Reduced test file fragmentation (19+ files → 6 files) - Improved maintainability with shared utilities - Better logical organization by functionality - Preserved all existing test functionality - Enhanced developer experience with meaningful test groupings
…tream handling - Consolidated fragmented test classes into organized partial classes - Added StreamTestHelpers utility class with TrackingStream for better stream disposal testing - Improved stream handling tests with proper disposal verification - Fixed BigInteger overflow test to not expect exceptions - Updated diagnostics tests to reflect current implementation behavior - Removed deprecated null crypto path tests and local KEK implementations - Enhanced test maintainability by reducing class fragmentation from 19+ to 5 logical groupings
- Remove Visual Studio version changes (17 -> 16) - Remove build configurations for unrelated project - Keep solution file consistent with upstream
Contributor
Author
|
@microsoft-github-policy-service agree company="Microsoft" |
Contributor
Author
|
/azp run |
|
Commenter does not have sufficient privileges for PR 5349 in repo Azure/azure-cosmos-dotnet-v3 |
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
kirankumarkolli
approved these changes
Oct 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Template
Description
Introduces a set of tests for the EncryptionProcessor class. #4678